#!/usr/bin/env bash
xtarget=$1
fileOK=0
if [ -z "$xtarget" ];then echo "usage:$0 junit-result-xml">&2; exit; fi
if [ -r "$xtarget" ];then fileOK=1; else echo "file[$xtarget] does not exist, nor readable.">&2; exit; fi


xpath="/testsuite/@name"
testsuite=`xml sel -t -v "$xpath" $xtarget`
echo "TestSuite: $testsuite"

#to count total number of test cases.
cnt=`xml el $xtarget |grep -E "^testsuite/testcase$"|wc -l`
echo "total-cases: $cnt"

#to count total number of failure.
cnt=`xml el $xtarget |grep -E "^testsuite/testcase/failure$"|wc -l`
echo "total-failure: $cnt"

#xpath="/testsuite/testcase[failure]/@name|//failure"
#xml sel -t -v "$xpath" $xtarget

